home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from base.g import *
- from base import device, utils
- from prnt import cups
- from base.codes import *
- from ui_utils import *
- from PyQt4.QtCore import *
- from PyQt4.QtGui import *
- from printdialog_base import Ui_Dialog
- from filetable import FileTable, FILETABLE_TYPE_PRINT
- from printernamecombobox import PRINTERNAMECOMBOBOX_TYPE_PRINTER_ONLY
- PAGE_FILE = 0
- PAGE_OPTIONS = 1
- PAGE_MAX = 1
-
- class PrintDialog(QDialog, Ui_Dialog):
-
- def __init__(self, parent, printer_name, args = None):
- QDialog.__init__(self, parent)
- self.setupUi(self)
- self.printer_name = printer_name
- self.user_settings = UserSettings()
- self.user_settings.load()
- self.user_settings.debug()
- self.initUi()
- self.file_list = []
- if args is not None:
- for a in args:
- self.Files.addFileFromUI(os.path.abspath(a))
-
-
- self.devices = { }
- QTimer.singleShot(0, self.updateFilePage)
-
-
- def initUi(self):
- self.OptionsToolBox.include_job_options = True
- self.connect(self.CancelButton, SIGNAL('clicked()'), self.CancelButton_clicked)
- self.connect(self.BackButton, SIGNAL('clicked()'), self.BackButton_clicked)
- self.connect(self.NextButton, SIGNAL('clicked()'), self.NextButton_clicked)
- self.initFilePage()
- self.initOptionsPage()
- self.setWindowIcon(QIcon(load_pixmap('hp_logo', '128x128')))
- if self.printer_name:
- self.PrinterName.setInitialPrinter(self.printer_name)
-
- self.StackedWidget.setCurrentIndex(0)
-
-
- def initFilePage(self):
- self.Files.setType(FILETABLE_TYPE_PRINT)
- self.Files.setWorkingDir(self.user_settings.working_dir)
- self.connect(self.Files, SIGNAL('isEmpty'), self.Files_isEmpty)
- self.connect(self.Files, SIGNAL('isNotEmpty'), self.Files_isNotEmpty)
-
-
- def updateFilePage(self):
- self.NextButton.setText(self._PrintDialog__tr('Next >'))
- self.NextButton.setEnabled(self.Files.isNotEmpty())
- self.BackButton.setEnabled(False)
- self.updateStepText(PAGE_FILE)
- self.Files.updateUi()
-
-
- def Files_isEmpty(self):
- self.NextButton.setEnabled(False)
-
-
- def Files_isNotEmpty(self):
- self.NextButton.setEnabled(True)
-
-
- def initOptionsPage(self):
- self.BackButton.setEnabled(True)
- self.PrinterName.setType(PRINTERNAMECOMBOBOX_TYPE_PRINTER_ONLY)
- self.connect(self.PrinterName, SIGNAL('PrinterNameComboBox_currentChanged'), self.PrinterNameComboBox_currentChanged)
- self.connect(self.PrinterName, SIGNAL('PrinterNameComboBox_noPrinters'), self.PrinterNameComboBox_noPrinters)
-
-
- def updateOptionsPage(self):
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
-
- try:
- self.PrinterName.updateUi()
- self.BackButton.setEnabled(True)
- num_files = len(self.Files.file_list)
- if num_files > 1:
- self.NextButton.setText(self._PrintDialog__tr('Print %1 Files').arg(num_files))
- else:
- self.NextButton.setText(self._PrintDialog__tr('Print File'))
- self.updateStepText(PAGE_OPTIONS)
- finally:
- QApplication.restoreOverrideCursor()
-
-
-
- def PrinterNameComboBox_currentChanged(self, device_uri, printer_name):
-
- try:
- self.devices[device_uri]
- except KeyError:
- self.devices[device_uri] = device.Device(device_uri)
-
- self.OptionsToolBox.updateUi(self.devices[device_uri], printer_name)
-
-
- def PrinterNameComboBox_noPrinters(self):
- FailureUI(self, self._PrintDialog__tr('<b>No printers found.</b><p>Please setup a printer and try again.'))
- self.close()
-
-
- def executePrint(self):
- for cmd in self.OptionsToolBox.getPrintCommands(self.Files.file_list):
- log.debug(cmd)
- (status, output) = utils.run(cmd, log_output = True, password_func = None, timeout = 1)
- if status != 0:
- FailureUI(self, self._PrintDialog__tr('<b>Print command failed with status code %1.</b><p>%2</p>').arg(status).arg(cmd))
- continue
-
- self.close()
-
-
- def CancelButton_clicked(self):
- self.close()
-
-
- def BackButton_clicked(self):
- p = self.StackedWidget.currentIndex()
- if p == PAGE_OPTIONS:
- self.StackedWidget.setCurrentIndex(PAGE_FILE)
- self.updateFilePage()
- else:
- log.error('Invalid page!')
-
-
- def NextButton_clicked(self):
- p = self.StackedWidget.currentIndex()
- if p == PAGE_FILE:
- self.StackedWidget.setCurrentIndex(PAGE_OPTIONS)
- self.updateOptionsPage()
- elif p == PAGE_OPTIONS:
- self.executePrint()
-
-
-
- def updateStepText(self, p):
- self.StepText.setText(self._PrintDialog__tr('Step %1 of %2').arg(p + 1).arg(PAGE_MAX + 1))
-
-
- def __tr(self, s, c = None):
- return qApp.translate('PrintDialog', s, c)
-
-
-